package org.example.diet_compass.mapper;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.diet_compass.domain.Orders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.lang.reflect.Array;
import java.util.ArrayList;

/**
* @author 86135
* @description 针对表【orders(存储订单信息的表)】的数据库操作Mapper
* @createDate 2025-03-16 11:01:05
* @Entity org.example.diet_compass.domain.Orders
*/
public interface OrdersMapper extends BaseMapper<Orders> {

    @Select("select count(order_id) from orders where user_id=#{userId} and status = #{state}")
    Integer getByUserIdAndState(int userId, String state);

    @Select("select order_id from orders where user_id=#{userId} and status = #{state} ")
    ArrayList<Integer> getOrderId(int userId, String state);
    @Update("update orders set status = #{status} where order_id = #{orderId}")
    void updateOrderState(Integer orderId, String status);
    @Select("select user_id from orders where order_id = #{orderId}")
    int getUserIdByOrderId(Integer orderId);
}




